var fs = require('fs');
var iconv = require('iconv-lite');

fs.readFile('./1.txt', function(err, data) {
    if (err) {
        console.error(err);
    } else {
        //把gbk流转换成utf8字符串
        var str = iconv.decode(data, 'gbk')+"服务1 ";
        //把utf8字符串转换成gbk流
        fs.writeFile('./1.txt', iconv.encode(str, 'gbk'), null, function (err) {
            if (err) throw err;
            console.log('It\'s saved!');
        });
    }
});